<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<script type="text/javascript">
	$(function() {
		/*获取角色数据*/
		$('#roleIds').combotree({
			url : '${pageContext.request.contextPath}/role/selectAllRoles',
			lines : true,
			panelHeight : '300',
			multiple : true,
			required: true,
			cascadeCheck : false,
			onLoadError:function(e){
				if(e.readyState==4){
					parent.$.messager.alert('错误',"获取角色数据失败，服务器错误！", 'error');
				}
				
			},
			value : $.stringToList('${userBo.roleIds}')
		});
		/*更新用户提交表单*/
		$('#demoEditForm').form({
			//async: false,
			url : '${ctx}/userManger/updateUser',
			
			onSubmit : function() {
				progressLoad();
				var ids=$("#roleIds").combotree('getValues');
			 	if (ids == null || ids == 0 || ids == '') {
				    progressClose();
					parent.$.messager.alert('提示', "请选择角色！", 'info');
					return false;
				} 
			},
			success : function(result) {
				progressClose();
				var res=result.toString();
				if (res=='修改成功') {
					parent.show("编辑成功","提示");
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				} else {
					parent.$.messager.alert('错误', result, 'error');
				}
			}
		});
	
	});
	/**清空删选框数据*/
	function cleanFun() {
		$('#searchForm').val('');
	}
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;">
		<form id="demoEditForm" method="post">
			<table class="grid">
				<tr>
					<td>备注</td>
					<td colspan="3">
						<textarea id="note" name="notes">${userBo.notes}</textarea>
					</td>
				</tr>
				<tr>
					<td>角色</td>
					<td colspan="3"><select id="roleIds"  name="roleIds" style="width: 140px; height: 29px;"></select>
					<font color="red" style="font-weight:bold;" face="verdana">&nbsp;*</font>
					</td>
				</tr>
			</table>
			<input name="userId" id ="userId" type="hidden"  value="${userBo.userId}"/>
		</form>
	</div>
</div>